//
//  SEGNewFutureViewController.m
//  SEGUhomeStandard
//
//  Created by 刘山 on 2018/3/20.
//  Copyright © 2018年 刘山. All rights reserved.
//

#import "SEGNewVersionViewController.h"
#import "SEGNewVersionViewModel.h"

@interface SEGNewVersionViewController ()
@property (nonatomic, strong) UIScrollView *backgrooundView;
@property(nonatomic, strong) SEGNewVersionViewModel *viewModel;
@end

@implementation SEGNewVersionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view addSubview:self.backgrooundView];
    self.backgrooundView.frame = self.view.bounds;
    self.backgrooundView.pagingEnabled = YES;
    self.backgrooundView.bounces = NO;
    self.backgrooundView.alwaysBounceHorizontal = YES;
    self.navDisplayType = SEGNavigationBarDisplayTypeHide;
    
    NSArray *dataSource = [self.viewModel datasSourceForLaunch];
    [dataSource enumerateObjectsUsingBlock:^(NSString*  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        
        UIImageView *showImageView = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenWidth * idx, 0, kScreenWidth, kLYScreenHeight())];
        showImageView.image = [UIImage imageWithContentsOfFile:obj];
        showImageView.contentMode = UIViewContentModeScaleAspectFill;
        showImageView.layer.masksToBounds = YES;
        showImageView.frame = CGRectMake(kScreenWidth * idx, 0, kScreenWidth, kLYScreenHeight());
        [self.backgrooundView addSubview:showImageView];
        
        if (idx == dataSource.count - 1) {
            showImageView.userInteractionEnabled = YES;
            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithActionBlock:^(UITapGestureRecognizer*  _Nonnull sender) {
                [[SEGUhomeMediator sharedInstance]seg_pushToMainViewControllerThroughInterface:nil];
            }];
            [showImageView addGestureRecognizer:tap];
        }
    }];
    self.backgrooundView.contentSize = CGSizeMake(dataSource.count * kScreenWidth, 0);
}
-(UIScrollView *)backgrooundView{
    if (!_backgrooundView) {
        _backgrooundView = [[UIScrollView alloc]init];
        _backgrooundView.backgroundColor = [UIColor whiteColor];
        _backgrooundView.contentSize = CGSizeMake(0, 0);
        _backgrooundView.showsVerticalScrollIndicator = NO;
        _backgrooundView.showsHorizontalScrollIndicator = NO;
    }
    return _backgrooundView;
}


#pragma mark - init Views
-(void)segInitViews{

}

#pragma mark - RAC Data Binding
- (void)bindViewModel {
}

#pragma mark - getter
-(SEGNewVersionViewModel *)viewModel{
    if (!_viewModel) {
        _viewModel = [[SEGNewVersionViewModel alloc]init];
    }
    return _viewModel;
}
@end
/*
 _backgrooundView = [[UIImageView alloc]init];
 _backgrooundView.image = [UIImage imageWithContentsOfFile:SEGPicName(@“”)];
 _backgrooundView.contentMode = UIViewContentModeScaleAspectFill;
 _backgrooundView.layer.masksToBounds = YES;
 //_backgrooundView.layer.cornerRadius = 0.5;
 if (kDebug)_backgrooundView.backgroundColor = kSegRandomColor;
 */
